import './App.css';
import { Redirect, Route, Switch } from 'react-router-dom';

//rcc 生成类组件
//rsf 生成函数式组件

import React, { Component, lazy, Suspense } from 'react';

// 懒加载
var Index = lazy(() => import('./views/Index'))
var Login = lazy(() => import('./views/Login'))
var Register = lazy(() => import('./views/Register'))
var NotFound = lazy(() => import('./views/NotFound'))

class App extends Component {
  render() {
    return (
      <div className='app'>
        <Suspense fallback={<div>loging...</div>}>
          <Switch>
            <Route path='/index' component={Index} />
            <Route exact path='/login' component={Login} />
            <Route exact path='/register' component={Register} />
            <Redirect exact from='/' to='/index' />
            <Route path='*' component={NotFound} />
          </Switch>
        </Suspense>
      </div>
    );
  }
}
export default App;